package com.example.crondemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author yanbl
 * @version V1.8
 * @Description: swagger2 config
 * @Date 2021/6/30 16:03
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 配置需要api的包
                .apis(RequestHandlerSelectors.basePackage("com.example.crondemo.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    // 设置api的基本信息
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("test")
                .description("服务名： service-corn")
                .version("1.0")
                .build();
    }
}
